package com.example.other.date;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;

public class Test {
    public static void main(String[] args) {

        DateTime dateTime = DateTime.parse("2018-7-31", DateTimeFormat.forPattern("yyyy-MM-dd"));

        System.out.println(dateTime.plusMonths(1));
        System.out.println(dateTime.minusMonths(1));

        DateTime dateTime2 = DateTime.parse("2018-2-28", DateTimeFormat.forPattern("yyyy-MM-dd"));

        System.out.println(dateTime2.plusMonths(1));
        System.out.println(dateTime2.minusMonths(1));

        DateTime dateTime3 = DateTime.parse("2018-1-30", DateTimeFormat.forPattern("yyyy-MM-dd"));

        System.out.println(dateTime3.plusMonths(1));
        System.out.println(dateTime3.minusMonths(1));
    }
}
